﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace RiskMan.DataClass.Models.RM
{
    /// <summary>
    /// Модуль РМ - лимиты по сделкам и ДС
    /// </summary>
    [Serializable]
    public class LimitMoneyAndDealsModel : ISerializable, INotifyPropertyChanged
    {
      #region private
        private bool _check;
        private String _account;
        private List<String> _accountList;
        private bool _isRun;
        private String _clientCode;
        private List<String> _clientCodeList;


        private double _limitMoney;
        private String _limiMoneyType;
        private int _limitDeals;
        private int _seriesLossDeals;
        private int _timePause;
        private double _lossAtInterval;
        private int _interval;
        private int _dealsLossAtPeriod;
        private int _periodLossDeals;

        #endregion

        #region public

        public bool Check
        {
            get { return _check; }
            set
            {
                if (_check != value)
                {
                    _check = value;
                    RaisePropertyChanged("Check");
                }
            }
        }
        public String Account
        {
            get { return _account; }
            set
            {
                if (_account != value)
                {
                    _account = value;
                    RaisePropertyChanged("Account");
                }
            }
        }
        public List<String> AccountList
        {
            get { return _accountList; }
            set
            {
                if (_accountList != value)
                {
                    _accountList = value;
                    RaisePropertyChanged("AccountList");
                }
            }
        }
        public String ClientCode
        {
            get { return _clientCode; }
            set
            {
                if (_clientCode != value)
                {
                    _clientCode = value;
                    RaisePropertyChanged("ClientCode");
                }
            }

        }
        public List<String> ClientCodeList
        {
            get { return _clientCodeList; }
            set
            {
                if (_clientCodeList != value)
                {
                    _clientCodeList = value;
                    RaisePropertyChanged("ClientCodeList");
                }
            }
        }
        public bool IsRun
        {
            get { return _isRun; }
            set
            {
                if (_isRun != value)
                {
                    _isRun = value;
                    RaisePropertyChanged("IsRun");
                }
            }
        }

        public double LimitMoney
        {
            get { return _limitMoney; }
            set
            {
                if (_limitMoney != value)
                {
                    _limitMoney = value;
                    RaisePropertyChanged("LimitMoney");
                }
            }
        }
        public String LimiMoneyType
        {
            get { return _limiMoneyType; }
            set
            {
                if (_limiMoneyType != value)
                {
                    _limiMoneyType = value;
                    RaisePropertyChanged("LimiMoneyType");
                }
            }
        }
        public int LimitDeals
        {
            get { return _limitDeals; }
            set
            {
                if (_limitDeals != value)
                {
                    _limitDeals = value;
                    RaisePropertyChanged("LimitDeals");
                }
            }
        }
        public int SeriesLossDeals
        {
            get { return _seriesLossDeals; }
            set
            {
                if (_seriesLossDeals != value)
                {
                    _seriesLossDeals = value;
                    RaisePropertyChanged("SeriesLossDeals");
                }
            }
        }
        public int TimePause
        {
            get { return _timePause; }
            set
            {
                if (_timePause != value)
                {
                    _timePause = value;
                    RaisePropertyChanged("TimePause");
                }
            }
        }
        public double LossAtInterval
        {
            get { return _lossAtInterval; }
            set
            {
                if (_lossAtInterval != value)
                {
                    _lossAtInterval = value;
                    RaisePropertyChanged("LossAtInterval");
                }
            }
        }
        public int Interval
        {
            get { return _interval; }
            set
            {
                if (_interval != value)
                {
                    _interval = value;
                    RaisePropertyChanged("Interval");
                }
            }
        }
        public int DealsLossAtPeriod
        {
            get { return _dealsLossAtPeriod; }
            set
            {
                if (_dealsLossAtPeriod != value)
                {
                    _dealsLossAtPeriod = value;
                    RaisePropertyChanged("DealsLossAtPeriod");
                }
            }
        }
        public int PeriodLossDeals
        {
            get { return _periodLossDeals; }
            set
            {
                if (_periodLossDeals != value)
                {
                    _periodLossDeals = value;
                    RaisePropertyChanged("PeriodLossDeals");
                }
            }
        }

        #endregion

        #region OnPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        
        #endregion

        public LimitMoneyAndDealsModel() { }

        public LimitMoneyAndDealsModel(SerializationInfo info, StreamingContext context)
        {
            Check = info.GetBoolean("Check");
            Account = info.GetString("Account");
            AccountList = (List<String>)info.GetValue("AccountList", typeof(List<String>));
            ClientCode = info.GetString("ClientCode");
            ClientCodeList = (List<String>)info.GetValue("ClientCodeList", typeof(List<String>));
            IsRun = info.GetBoolean("IsRun");

            LimitMoney = info.GetDouble("LimitMoney");
            LimiMoneyType = info.GetString("LimiMoneyType");
            LimitDeals = info.GetInt32("LimitDeals");
            SeriesLossDeals = info.GetInt32("SeriesLossDeals");
            TimePause = info.GetInt32("TimePause");
            LossAtInterval = info.GetDouble("LossAtInterval");
            Interval = info.GetInt32("Interval");
            DealsLossAtPeriod = info.GetInt32("DealsLossAtPeriod");
            PeriodLossDeals = info.GetInt32("PeriodLossDeals");
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Check", Check);
            info.AddValue("Account", Account);
            info.AddValue("AccountList", AccountList);
            info.AddValue("ClientCode", ClientCode);
            info.AddValue("ClientCodeList", ClientCodeList);
            info.AddValue("IsRun", IsRun);

            info.AddValue("LimitMoney", LimitMoney);
            info.AddValue("LimiMoneyType", LimiMoneyType);
            info.AddValue("LimitDeals", LimitDeals);
            info.AddValue("SeriesLossDeals", SeriesLossDeals);
            info.AddValue("TimePause", TimePause);
            info.AddValue("LossAtInterval", LossAtInterval);
            info.AddValue("Interval", Interval);
            info.AddValue("DealsLossAtPeriod", DealsLossAtPeriod);
            info.AddValue("PeriodLossDeals", PeriodLossDeals);

        }
    }
}
